#include "event_target.h"

EventTarget::EventTarget() { }
EventTarget::~EventTarget() { }

bool EventTarget::OnEvent(SDL_Event* Event) {
    switch(Event->type) {
        case SDL_ACTIVEEVENT: {
            switch(Event->active.state) {
                case SDL_APPMOUSEFOCUS: {
                    if ( Event->active.gain )
						return OnMouseFocus();
                    else
						return OnMouseBlur();
                    break;
                }
                case SDL_APPINPUTFOCUS: {
                    if ( Event->active.gain )
						return OnInputFocus();
                    else
						return OnInputBlur();
                    break;
                }
                case SDL_APPACTIVE:    {
                    if ( Event->active.gain )
						return OnRestore();
                    else
						return OnMinimize();
                    break;
                }
            }
            break;
        }
 
        case SDL_KEYDOWN: {
            return OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
            break;
        }
 
        case SDL_KEYUP: {
            return OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode);
            break;
        }
 
        case SDL_MOUSEMOTION: {
            return OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
            break;
        }
 
        case SDL_MOUSEBUTTONDOWN: {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    return OnLButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    return OnRButtonDown(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    return OnMButtonDown(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_MOUSEBUTTONUP:    {
            switch(Event->button.button) {
                case SDL_BUTTON_LEFT: {
                    return OnLButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    return OnRButtonUp(Event->button.x,Event->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    return OnMButtonUp(Event->button.x,Event->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_JOYAXISMOTION: {
            return OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value);
            break;
        }
 
        case SDL_JOYBALLMOTION: {
            return OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel);
            break;
        }
 
        case SDL_JOYHATMOTION: {
            return OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value);
            break;
        }
        case SDL_JOYBUTTONDOWN: {
            return OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_JOYBUTTONUP: {
            return OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button);
            break;
        }
 
        case SDL_QUIT: {
            return OnExit();
            break;
        }
 
        case SDL_SYSWMEVENT: {
            //Ignore
            break;
        }
 
        case SDL_VIDEORESIZE: {
            return OnResize(Event->resize.w,Event->resize.h);
            break;
        }
 
        case SDL_VIDEOEXPOSE: {
            return OnExpose();
            break;
        }
 
        default: {
            return OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2);
            break;
        }
    }

	//If nothing caught the type, it wasn't processed or captured.
	return false;
}
 
bool EventTarget::OnInputFocus() {
    return false;
}
 
bool EventTarget::OnInputBlur() {
    return false;
}
 
bool EventTarget::OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode) {
    return false;
}
 
bool EventTarget::OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode) {
    return false;
}
 
bool EventTarget::OnMouseFocus() {
    return false;
}
 
bool EventTarget::OnMouseBlur() {
    return false;
}
 
bool EventTarget::OnMouseMove(int mX, int mY, int relX, int relY, bool Left,bool Right,bool Middle) {
    return false;
}
 
bool EventTarget::OnMouseWheel(bool Up, bool Down) {
    return false;
}
 
bool EventTarget::OnLButtonDown(int mX, int mY) {
    return false;
}
 
bool EventTarget::OnLButtonUp(int mX, int mY) {
    return false;
}
 
bool EventTarget::OnRButtonDown(int mX, int mY) {
    return false;
}
 
bool EventTarget::OnRButtonUp(int mX, int mY) {
    return false;
}
 
bool EventTarget::OnMButtonDown(int mX, int mY) {
    return false;
}
 
bool EventTarget::OnMButtonUp(int mX, int mY) {
    return false;
}
 
bool EventTarget::OnJoyAxis(Uint8 which,Uint8 axis,Sint16 value) {
    return false;
}
 
bool EventTarget::OnJoyButtonDown(Uint8 which,Uint8 button) {
    return false;
}
 
bool EventTarget::OnJoyButtonUp(Uint8 which,Uint8 button) {
    return false;
}
 
bool EventTarget::OnJoyHat(Uint8 which,Uint8 hat,Uint8 value) {
    return false;
}
 
bool EventTarget::OnJoyBall(Uint8 which,Uint8 ball,Sint16 xrel,Sint16 yrel) {
    return false;
}
 
bool EventTarget::OnMinimize() {
    return false;
}
 
bool EventTarget::OnRestore() {
    return false;
}
 
bool EventTarget::OnResize(int w,int h) {
    return false;
}
 
bool EventTarget::OnExpose() {
    return false;
}
 
bool EventTarget::OnExit() {
    return false;
}
 
bool EventTarget::OnUser(Uint8 type, int code, void* data1, void* data2) {
    return false;
}
